<extend name="Public/user"/>
<block name="link">
	<title>我要下单</title>
	<link href="/static/lida/css/tran_style.css" rel="stylesheet" type="text/css" />
	<link href="__CSS__/bootstrap.css" rel="stylesheet"/>
	<script src="__JS__/jquery.js"></script>
	<script src="__JS__/bootstrap.js"></script>
	<script src="__JS__/layer/layer.js"></script>
	<script type="text/javascript" src="__STATIC__/thinkbox/thinkbox/jquery.thinkbox.js"></script>
	<script type="text/javascript" src="__JS__/style.js"></script>
	<link href="__CSS__/ksfh-style.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
</block>
<block name="user-right">
	<!--main_right-->
	<div class="main_r f_fr">
		<div class="user_kx">
			<h3 class="user_kx_title">
				{:lang('order_info')}
			</h3>
			<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				<tbody>
				<tr>
					<td width="80">{:lang('order_num')}：</td>
					<td>{$ddinfo.sn}</td>
					<td>{:lang('add_time')}：</td>
					<td>{$ddinfo.addtime|time_format}</td>
				</tr>
				<tr>
					<td>{:lang('delivery_info')}：</td>
					<td colspan="3">{$ddinfo.consignee}({$ddinfo.tel}) &nbsp; {$ddinfo.areaname} {$ddinfo.address}({$ddinfo.zipcode})</td>
				</tr>
				<tr>
					<td>{:lang('freight_info')}：</td>
					<td colspan="3">{$ddinfo.freight_info}</td>
				</tr>
				<tr>
					<td>{:lang('remark')}：</td>
					<td colspan="3">{$ddinfo.remark}</td>
				</tr>
				<tr>
					<td>费用总计：</td>
					<td colspan="3"><span  style="font-size: 16px;font-weight: bold;display: inline-block;padding: 0 5px;color: red;">{$ddinfo.freight}{:config('MAIN_COIN')}</span></td>
				</tr>
				</tbody>
			</table>
		</div>
		<div class="user_kx">
			<h5 class="user_kx_title">运费支付</h5>
			<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				<tbody>
				<tr>
					<td><label> <input type="radio" name="pay_method" onclick="predeposits(1)" value="predeposit" <php>if($member['available_predeposit']<$ddinfo['freight']){echo
							'disabled';};</php> > 使用预存款支付 （可用余额：{$member.available_predeposit}日元）
					</label> <php>if($member['available_predeposit']<$ddinfo['freight']){</php>
						在线充值可获取积分&nbsp;
						<a href="/store/member/index.php?act=predeposit&op=recharge_add" target="_blank" class=" btn btn-info">立即充值</a> <php>}</php>
						<form class="form-inline pd_pay_form" style="padding-left: 15px; display: none">
							<div class="form-group">
								<label >请输入支付密码：</label> 
								<input type="password" id="input_pd_password"  class="form-control input-sm" style="height: 20px;" placeholder="默认为登陆密码"> 
								<a href="javascript:void(0);" class="btn btn-danger input-sm" id="pd_pay_submit">验证密码</a>
							</div>
						</form></td>
				</tr>
				<tr>
					<td>选择在线支付：
					 <label class="radio-inline"> 
					<input type="radio" name="pay_method" value="wechat" onclick="predeposits(0)"> 微信
					</label> 
					<label class="radio-inline"> 
					<input type="radio" name="pay_method" value="alipay" onclick="predeposits(0)"> 支付宝
					</label>
					</td>
				</tr>
				<tr>
					<td>
						<div style="width: 200px; line-height: 20px;">
							<a href="javascript:;" class=" btn btn-danger" style="background: #2CDE98; border: 1px solid #2CDE98;" id="querenzhifu">{:lang('confirm_pay')}</a>
						</div>
					</td>
				</tr>
			</tbody>
			</table>
		
		</div>

	</div>
</block>
<block name="javascript">
<script type="text/javascript">
	var iframe;
	function predeposits(check) {
		if (1 == check) {
			$('.pd_pay_form').show();
			$('#querenzhifu').hide();
		} else {
			$('.pd_pay_form').hide();
			$('#querenzhifu').show();
		}
	}

	$("#pd_pay_submit").click(function() {
		var loading = $.thinkbox.loading('努力验证中');
		$.post("{:url('User/checkPdPay')}", {
			password : $("#input_pd_password").val(),
			money:{$ddinfo.freight}
		}, function(data) {
			if(0 == data.code){
				$.thinkbox.success(data.message);
				$('#querenzhifu').show();
				$('.pd_pay_form').hide();
			}else{
				$.thinkbox.error(data.message);
			}
			loading.hide();
		})
	});
	$("#querenzhifu").click(function() {
		if(undefined ==$('input[name="pay_method"]:checked ').val()){
			$.thinkbox.error('请选择支付方式');
		}else{
			var loading = $.thinkbox.loading('努力支付中');
			$.post("{:url('')}", {
				pay_method : $('input[name="pay_method"]:checked ').val(),
				password : $("#input_pd_password").val(),
				id:{$ddinfo.id}
			}, function(data) {
				loading.hide();
				if(0 == data.code){
					$.thinkbox.success(data.message);
					$('#querenzhifu').show();
					$('.pd_pay_form').hide();
				}else if(10 == data.code)
				{
					$.thinkbox.success(data.message);
					setTimeout(jumpurl(data.url),1000);
				}else if(20 == data.code)
				{
					iframe = layer.open({
						  type: 2,
						  title: '微信扫一扫支付',
						  shadeClose: true,
						  shade: 1,
						  area: ['880px', '500px'],
						  content: "{:url('Public/qrcode')}&url="+data.url //iframe的url
						}); 
					setInterval('getQuery()',2000);
				}else{
					$.thinkbox.error(data.message);
				}
			})
		}
	});
	function getQuery()
	{
		$.post("{:url('User/query')}", {
			id:{$ddinfo.id}
		}, function(data) {
			if(0 == data.code){
				layer.close(iframe);
				layer.msg(data.message);
				setTimeout(jumpurl(data.url),1000);
			}else{
				console.log(1);
				//$.thinkbox.error(data.message);
			}
		})
	}
</script>
</block>